package com.lc.controller;

import com.lc.entity.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * Author:LC
 * Version:jdk-8u301
 * Date: 2022/7/18 14:29
 */
@RestController
public class TestController {

    @GetMapping("/testGet01")
    public String get01(String name){
        System.out.println(name);
        return "get..ok";
    }



    /**
     * post传参两种方式：
     *      1.json对象的形式： header中 content-type = application/json;charset=utf-8;
     *      2.接收表单参数,可以直接使用对象接收；
     */
    @PostMapping("/testPost01")
    public String post01(@RequestBody User user){
        System.out.println(user);
        return "post01..ok";
    }



    @PostMapping("/testPost02")
    public String post02(User user){
        System.out.println(user);
        return user.toString();
    }

}
